<template>
  <div>
    <div class="flex flex-col h-full">
      <SearchContainer @search="getData" @reset="() => formRef.resetFields()">
        <a-form ref="formRef" class="flex-1" :model="formState" :colon="false" :label-col="{ style: { width: '70px' } }">
          <a-form-item name="mcbh" class="w-64">
            <a-input v-model:value="formState.mcbh" placeholder="编号/名称/助记码" />
          </a-form-item>
        </a-form>
      </SearchContainer>
      <a-card class="mt-2 flex-1">
        <div class="flex justify-end mb-3">
          <BaseExport type="运维" name="服用方法" code="00001060" :search-params="formState">导出</BaseExport>
          <!-- <a-button @click="onExport">导出</a-button> -->
        </div>
        <BaseTable :loading="loading" column-code="00001060" fill :data-source="tableData" bordered :pagination="pagination">
          <template #bodyCell="{ column, index, record }">
            <template v-if="column.dataIndex === 'xh'">
              {{ index + 1 }}
            </template>
            <template v-if="column.dataIndex === 'syffStr'"> {{ getSign(record) }} </template>
          </template>
        </BaseTable>
      </a-card>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import SearchContainer from '@/components/SearchContainer'
import BaseTable from '@/components/BaseTable'

const formRef = ref(null)
const formState = ref({})
const getSign = (item) => {
  const sign = ref(null)
  switch (item.sfsy) {
    case 0:
      sign.value = '无'
      break
    case 1:
      sign.value = '输液'
      break
    case 2:
      sign.value = '注射'
      break
  }
  return sign.value
}
const { loading, tableData, getData, pagination } = useTable({
  url: '/operation/opex/getTakeMedicineDictInfoList',
  immediate: true,
  params: formState.value
})
</script>
<style lang="less" scoped>
.ant-picker {
  width: 100%;
}
</style>
